#ifndef RANDOM_H
#define RANDOM_H

#include <random>
#include "globals.h"

#define RL(LIST) LIST[Random::get<int>(0,LIST.size()-1)]

class Random
{
  static std::random_device device;
  static std::default_random_engine engine;
public:
  static void init()
  {
    engine = std::default_random_engine(device());
  }

  template<typename T>
  static T get(T range_min,T range_max)
  {
    std::uniform_int_distribution<T> uniform_dist(range_min,range_max);
    return uniform_dist(engine);
  }

  static bool check(double probability)
  {
    Q_ASSERT(probability <= 100 && probability >= 0);
    return (get<int>(1,100) <= probability*100);
  }
};

#endif // RANDOM_H
